package com.mrobuy.jd.product;

import com.gavel.database.SQLExecutor;
import com.google.gson.Gson;
import com.jd.open.api.sdk.JdClient;
import com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.get.ExtPropDto;
import com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.get.PropSetting;
import com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.get.SingleProductInfoDto;
import com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.get.SkuInfoDto;
import com.jd.open.api.sdk.request.supplier.VcItemProductGetRequest;
import com.jd.open.api.sdk.response.supplier.VcItemProductGetResponse;
import com.mrobuy.jd.JdClientFactory;
import com.mrobuy.jdvc.entity.*;
import com.mrobuy.util.IdentifierGen;

import java.util.List;

public class VcItemProductGet {

    public static void main(String[] args) throws Exception {


        List<VCProductInfo> vcProductInfos = SQLExecutor.executeQueryBeanList("select  * from VC_PRODUCT_INFO", VCProductInfo.class);


        for (VCProductInfo vcProductInfo : vcProductInfos) {
            load(vcProductInfo.getWareId(), JdClientFactory.jdClient());
        }

    }

    private static void load(String wareId, JdClient client) throws Exception {
        VcItemProductGetRequest request = new VcItemProductGetRequest();
        request.setWareId(wareId);
        VcItemProductGetResponse response = client.execute(request);

        System.out.println(new Gson().toJson(response));

        if (response.getJosResultDto().getIsSuccess()) {
            SingleProductInfoDto productInfo = response.getJosResultDto().getSingleObj();

            System.out.println(new Gson().toJson(productInfo));

            VCProduct product = null;
            try {
                product =  SQLExecutor.executeQueryBean("select * from VC_PRODUCT where wareId = ? ", VCProduct.class, wareId);
            } catch (Exception e) {
                e.printStackTrace();
            }

            boolean insert =  ( product==null);
            if ( insert ) {
                product = new VCProduct();
                product.setId(IdentifierGen.uuid());
            }

            product.setWareId(productInfo.getWareId());

            // *     @FieldMeta(name = "NAME", title = "名称", length = 128)
            product.setName(productInfo.getName());

            // *     @FieldMeta(name = "SUBMIT_TIME", title = "提交时间", length = 20)
            // product.setSubmitTime(productInfo.getSubmitTime());

            // *     @FieldMeta(name = "STATE", title = "状态")
            //product.setState("");

            // *     @FieldMeta(name = "CID1", title = "第一分类ID(三级分类)", length = 20)
            product.setCid1(String.valueOf(productInfo.getCid1()));

            // *     @FieldMeta(name = "CIDNAME1", title = "第一分类名称", length = 20)
            product.setCidName1(productInfo.getCidName1());

            // *     @FieldMeta(name = "BRANDID", title = "品牌ID", length = 20)
            product.setBrandid(String.valueOf(productInfo.getBrandId()));
            product.setBrandName(productInfo.getBrandName());

            // *     @FieldMeta(name = "ZHBRAND", title = "中文品牌", length = 50)
            product.setZhbrand(productInfo.getZhBrand());

            // *     @FieldMeta(name = "ENBRAND", title = "英文品牌", length = 50)
            product.setEnbrand(productInfo.getEnBrand());

            // *     @FieldMeta(name = "MODEL", title = "商品型号", length = 50)
            product.setModel(productInfo.getModel());

            // *     @FieldMeta(name = "TEL", title = "服务电话", length = 50)
            product.setTel(productInfo.getTel());

            // *     @FieldMeta(name = "WEBSITE", title = "官方网址", length = 256)
            product.setWebsite(productInfo.getWebSite());

            // *     @FieldMeta(name = "ORIGINALPLACE", title = "产地", length = 20)
            product.setOriginalplace(productInfo.getOriginalPlace());   // 中国大陆

            // *     @FieldMeta(name = "WARRANTY", title = "质保", length = 20)
            product.setWarranty(productInfo.getWarranty());    // 年质保	质保（最多可输入6个汉字）

            // *     @FieldMeta(name = "SHELFLIFE", title = "保质期", length = 8)
            product.setShelflife(String.valueOf(productInfo.getShelfLife()));    // 	365	保质期(单位：天)

            // *     @FieldMeta(name = "SALERCODE", title = "销售员简码", length = 20)
            product.setSalercode(productInfo.getSalerCode());
            product.setSalerName(productInfo.getSalerName());

            // *     @FieldMeta(name = "PURCHASERCODE", title = "采购员简码", length = 20)
            product.setPurchasercode(productInfo.getPurchaserCode());
            product.setPurchaserName(productInfo.getPurchaserName());

            // *     @FieldMeta(name = "PACKING", title = "包装规格", length = 20)
            product.setPacking(String.valueOf(productInfo.getPacking())); // 包装规格（[1×N]请填写N的值）

            // *     @FieldMeta(name = "PACKTYPE", title = "包装规格", length = 8)
            product.setPacktype(String.valueOf(productInfo.getPackType())); // 特殊属性（1:普通商品，2:易碎品，3:裸装液体，4:带包装液体，5:按原包装出库）

            // *     @FieldMeta(name = "SKUUNIT", title = "销售单位", length = 8)
            product.setSkuunit(productInfo.getSkuUnit()); // 箱	销售单位（必须为VC接口提供的销售单位）

            // *     @FieldMeta(name = "PKGINFO", title = "包装清单", length = 256)
            product.setPkginfo(productInfo.getPkgInfo()); // USB线 × 1	包装清单（格式：USB线 × 1、AV线 × 1、配带 × 1、说明书 × 1、保修卡 × 1 ，最多可录入20000个字符）


            // *     @FieldMeta(name = "INTROHTML", title = "PC 端商品介绍", length = 10000)
            if ( productInfo.getPcDecorationHtml()!=null ) {
                product.setIntrohtml(productInfo.getPcDecorationHtml());    // 	PC端代码录入的商品介绍
            }
            if ( productInfo.getIntroHtml()!=null ) {
                product.setIntrohtml(productInfo.getIntroHtml());    // 	PC端代码录入的商品介绍
            }


            // *     @FieldMeta(name = "INTROMOBILE", title = "Mobile 端商品介绍", length = 10000)
            if ( productInfo.getMobileDecorationHtml()!=null ) {
                product.setIntromobile(productInfo.getMobileDecorationHtml());    // 	Mobile端代码录入的商品介绍
            }
            if ( productInfo.getIntroMobile()!=null ) {
                product.setIntromobile(productInfo.getIntroMobile());    // 	Mobile端代码录入的商品介绍

            }

            // *     @FieldMeta(name = "INTRO", title = "商品介绍", length = 10000)
            product.setIntro("");    // 	原始的商品介绍

            // *     @FieldMeta(name = "VIDEOID", title = "视频介绍编号", length = 20)
            product.setVideoid(String.valueOf(productInfo.getVideoId()));    // 	视频介绍编号

            // *     @FieldMeta(name = "DANGERVALUE", title = "危险品的值", length = 20)
            product.setDangervalue(String.valueOf(productInfo.getDangerGoods()));    // 	danger_value	Number[]	否	1	危险品的值

            // *     @FieldMeta(name = "SYSP", title = "试用品标识", length = 8)
            product.setSysp(String.valueOf(productInfo.getSysp()));    // 	试用品标识[0:否 1:是]

            // *     @FieldMeta(name = "STOREPROPERTY", title = "冷链标记", length = 8)
            product.setStoreproperty(String.valueOf(productInfo.getStoreProperty()));    // 	冷链标记（1：控温（10 -18℃）;2：冷藏（0-8 ℃）;3：冷冻（零下12- 零下18 ℃）;4：深冷（零下30 ℃ ）;6:产地直送;7：鲜品（冷藏存常温配）;0或null：未设置）

            // *     @FieldMeta(name = "PRODUCTOILNUMBER", title = "成品油容量", length = 20)
            product.setProductoilnumber(String.valueOf(productInfo.getProductOilNumber()));    // 	成品油容量(正数，如果填写小数，小数位数长度不能超过6位)

            // *     @FieldMeta(name = "PRODUCTOILUNIT", title = "成品油容量", length = 20)
            product.setProductoilunit(productInfo.getProductOilUnit());    // 	成品油单位[大写的'L'(升)或者大写的'T'(吨)]

            // *     @FieldMeta(name = "GIFTSGOODS", title = "成品油容量", length = 8)
            product.setGiftsgoods(String.valueOf(productInfo.getGiftsGoods()));    // 	赠品标识[0:否 1:是不可销售 2：是可销售]

            // *     @FieldMeta(name = "DESIGNCONCEPT", title = "设计理念", length = 2000)
            product.setDesignconcept(productInfo.getDesignConcept());    // 	设计理念	设计理念


            // *     @FieldMeta(name = "HASTRANSFERELECCODE", title = "是否需要电子监管码", length = 8)
            // product.setHastransfereleccode(productInfo.getIsOverseaPurchase());    // 	是否需要电子监管码[0:不需要 1:需要]

            // *     @FieldMeta(name = "AFTERSALEDESC", title = "售后保障", length = 8)
            product.setAftersaledesc(productInfo.getAfterSaleDesc());    // 	售后保障图文详情字符串

            // *     @FieldMeta(name = "WREADME", title = "规格参数手工录入文本", length = 100)
            product.setWreadme(productInfo.getWreadme());    // 	鞋品材料：橡胶	规格参数手工录入文本

            // *     @FieldMeta(name = "TYPE", title = "资质类型", length = 100)
            //product.setType(productInfo.getT);    // 	-type	Number[]	否	2	资质类型

            // *     @FieldMeta(name = "APPLICANT", title = "3c证书委托人", length = 1000)
            // product.set applicant;    // 	-applicant	String[]	否	京东商城	3c证书委托人

            // *     @FieldMeta(name = "QCCODE", title = "3c证书编号", length = 1000)
            // product.set qccode;    // 	qc_code	String[]	否	123223445	3c证书编号

            // *     @FieldMeta(name = "ENDDATE", title = "资质到期日期", length = 1000)
            // product.set enddate;    // -end_date	Date[]	否	2016/8/9	资质到期日期

            // // -file_key_list	String[]	否	52c81484-7941-4017-a40b-d116d3b117a4.txt;52c81484-7941-4017-a40b-d116d3b117a4.txt	资质文件key列表，多个key中间用英文分号[;]进行分隔
            // *     @FieldMeta(name = "FILEKEYLIST", title = "资质文件key列表", length = 1000)
            // product.set filekeylist;

            if ( insert ) {
                SQLExecutor.insert(product);
            } else {
                SQLExecutor.update(product);
            }


            if ( productInfo.getSkuList()!=null && productInfo.getSkuList().size() > 0 ) {

                for (SkuInfoDto skuInfoDto : productInfo.getSkuList()) {

                    VCItem item = null;
                    try {
                        item =  SQLExecutor.executeQueryBean("select * from VC_ITEM where skuId = ? ", VCItem.class, skuInfoDto.getSkuId());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    insert =  ( item==null);
                    if ( insert ) {
                        item = new VCItem();
                        item.setId(IdentifierGen.uuid());
                    }

                    item.setWareId(productInfo.getWareId());


                    // *     @FieldMeta(name = "SKUID", title = "商品SKU", length = 32)
                    item.setSkuId(skuInfoDto.getSkuId());

                    // *     @FieldMeta(name = "SKUNAME", title = "商品名称", length = 100)
                    item.setSkuName(skuInfoDto.getSkuName());

                    // *     @FieldMeta(name = "UUID", title = "uuid", length = 32)
                    item.setUuid(skuInfoDto.getUuid());

                    // *     @FieldMeta(name = "DIM1VAL", title = "第一维度的销售属性值", length = 100)
                    item.setDim1Val(skuInfoDto.getDim1Val());

                    // *     @FieldMeta(name = "DIM1SORT", title = "第一维度销售属性顺序", length = 8)
                    item.setDim1Sort(String.valueOf(skuInfoDto.getDim1Sort()));

                    // *     @FieldMeta(name = "DIM2VAL", title = "第二维度的销售属性值", length = 100)
                    item.setDim2Val(skuInfoDto.getDim2Val());

                    // *     @FieldMeta(name = "DIM2SORT", title = "第二维度销售属性顺序", length = 8)
                    item.setDim2Sort(String.valueOf(skuInfoDto.getDim2Sort()));

                    // *     @FieldMeta(name = "OTHERSALEATTRIBUTE", title = "高维度(dim不小于3)销售属性列表", length = 1000)
                    // TODO  高维度(dim不小于3)销售属性列表
                    // item.setOtherSaleAttribute(skuInfoDto.getOtherSaleAttribute());

                    // *     @FieldMeta(name = "MARKETPRICE", title = "市场价", length = 20)
                    item.setMarketPrice(skuInfoDto.getMarketPrice().stripTrailingZeros().toPlainString()); // 	900	市场价（小数点后保留2位）

                    // *     @FieldMeta(name = "PURCHASEPRICE", title = "采购价", length = 20)
                    item.setPurchasePrice(skuInfoDto.getPurchasePrice().stripTrailingZeros().toPlainString()); // 700	采购价（小数点后保留2位）

                    // *     @FieldMeta(name = "MEMBERPRICE", title = "京东价(", length = 20)
                    item.setMemberPrice(skuInfoDto.getMemberPrice().stripTrailingZeros().toPlainString()); // 700	800	京东价(（小数点后保留2位）

                    // *     @FieldMeta(name = "WEIGHT", title = "商品重量", length = 20)
                    item.setWeight(skuInfoDto.getWeight().stripTrailingZeros().toPlainString()); // 	1.123	商品重量(单位：千克，含包装)小数点后保留3位

                    // *     @FieldMeta(name = "LENGTH", title = "长度", length = 20)
                    item.setLength(String.valueOf(skuInfoDto.getLength())); // 	1.123	长度(单位：毫米，含包装)

                    // *     @FieldMeta(name = "WIDTH", title = "宽度", length = 20)
                    item.setWidth(String.valueOf(skuInfoDto.getWidth())); // 	1.123	宽度(单位：毫米，含包装)

                    // *     @FieldMeta(name = "HEIGHT", title = "高度", length = 20)
                    item.setHeight(String.valueOf(skuInfoDto.getHeight())); // 	1.123	高度(单位：毫米，含包装)

                    // *     @FieldMeta(name = "UPC", title = "UPC编码", length = 20)
                    item.setUpc(skuInfoDto.getUpc()); // UPC编码（只包含字母和数字）

                    // *     @FieldMeta(name = "ITEMNUM", title = "货号", length = 20)
                    item.setItemNum(skuInfoDto.getItemNum()); // 132 货号（货号不能包括中文，只能为英文或数字）

                    //  Item原始数据属性
                    // *     @FieldMeta(name = "ORIGINALCODE", title = "原始数据", length = 20)
                    // item.set originalCode;

                    // *     @FieldMeta(name = "MODEL", title = "制造商型号", length = 20)
                    // item.set model;

                    // *     @FieldMeta(name = "DELIVERYDATE", title = "发货日期", length = 30)
                    // item.set deliverydate;

                    // *     @FieldMeta(name = "UNIT", title = "销售单位", length = 20)
                    // item.set unit;


                    if ( insert ) {
                        SQLExecutor.insert(item);
                    } else {
                        SQLExecutor.update(item);
                    }

                }

            } else {

                VCItem item = null;
                try {
                    item =  SQLExecutor.executeQueryBean("select * from VC_ITEM where skuId = ? ", VCItem.class, productInfo.getWareId());
                } catch (Exception e) {
                    e.printStackTrace();
                }

                insert =  ( item==null);
                if ( insert ) {
                    item = new VCItem();
                    item.setId(IdentifierGen.uuid());
                }

                item.setWareId(productInfo.getWareId());


                /**
                 * {
                 *     "wareId": "100016524002",
                 *     "name": "京苏 机用PP打包带",
                 *     "model": "机用PP打包带",
                 *     "originalPlace": "中国大陆",
                 *     "upc": "100016524002",
                 *     "packing": 1,
                 *     "skuUnit": "卷",
                 *     "packType": 1,
                 *     "pkgInfo": "1",
                 *     "warranty": "1个月质保",
                 *     "shelfLife": 7,
                 *     "zhBrand": "京苏",
                 *     "enBrand": "京苏",
                 *     "webSite": "",
                 *     "tel": "",
                 *     "length": 1300,
                 *     "width": 12,
                 *     "height": 1,
                 *     "weight": 1,
                 *     "marketPrice": 206,
                 *     "purchasePrice": 156,
                 *     "memberPrice": 176,
                 *     "brandId": 548836,
                 *     "brandName": "京苏",
                 *     "cid1": 14072,
                 *     "cidName1": "包装耗材",
                 *     "salerCode": "shaoshihao",
                 *     "salerName": "邵士昊",
                 *     "purchaserCode": "liujie192",
                 *     "purchaserName": "刘杰",
                 *     "vendorCode": "jsyg",
                 *     "vendorName": "京苏易购电子商务（江苏）有限公司",
                 *     "fullCategoryName1": "工业品---标签包装---包装耗材",
                 *     "introHtml": "<div class=\"detail-content-item\"> \n <div id=\"activity_header\" clstag=\"shangpin|keycount|product|activityheader\"></div> \n <div id=\"J-detail-content\"> \n  <style>.ssd-module-wrap {\n            position: relative;\n            margin: 0 auto;\n            width: 750px;\n            text-align: left;\n            background-color: #fff\n        }\n        .ssd-module-wrap .ssd-module, .ssd-module-wrap .ssd-module-heading {\n            width: 750px;\n            position: relative;\n            overflow: hidden\n        }\n        .ssd-module-wrap .ssd-module {\n            background-repeat: no-repeat;\n            background-position: left top;\n            background-size: 100% 100%\n        }\n        .ssd-module-wrap .ssd-module-heading {\n            background-repeat: no-repeat;\n            background-position: left center;\n            background-size: 100% 100%\n        }\n        .ssd-module-wrap .ssd-module-heading .ssd-module-heading-layout {\n            display: inline-block\n        }\n        .ssd-module-wrap .ssd-module-heading .ssd-widget-heading-ch {\n            float: left;\n            display: inline-block;\n            margin: 0 6px 0 15px;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-module-heading .ssd-widget-heading-en {\n            float: left;\n            display: inline-block;\n            margin: 0 15px 0 6px;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-widget-circle, .ssd-module-wrap .ssd-widget-line, .ssd-module-wrap .ssd-widget-pic, .ssd-module-wrap .ssd-widget-rectangle, .ssd-module-wrap .ssd-widget-table, .ssd-module-wrap .ssd-widget-text, .ssd-module-wrap .ssd-widget-triangle {\n            position: absolute;\n            overflow: hidden\n        }\n        .ssd-module-wrap .ssd-widget-triangle svg {\n            width: 100%;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-widget-table table {\n            width: 100%;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-widget-table td {\n            position: relative;\n            white-space: pre-line;\n            word-break: break-all\n        }\n        .ssd-module-wrap .ssd-widget-pic img {\n            display: block;\n            width: 100%;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-widget-text {\n            line-height: 1.5;\n            word-break: break-all\n        }\n        .ssd-module-wrap .ssd-widget-text span {\n            display: block;\n            overflow: hidden;\n            width: 100%;\n            height: 100%;\n            padding: 0;\n            margin: 0;\n            word-break: break-all;\n            word-wrap: break-word;\n            white-space: normal\n        }\n        .ssd-module-wrap .M16036958418651 {\n            width: 750px;\n            background-color: transparent;\n            background-image: url(//img30.360buyimg.com/sku/jfs/t2467/315/1479078334/2361/4757d7d6/566010f4N01f5d17a.png);\n            height: 30px;\n            text-align: left\n        }\n        .ssd-module-wrap .W16036958418662 {\n            background-color: transparent;\n            color: #ffffff;\n            font-weight: normal;\n            letter-spacing: 0px;\n            text-decoration: none;\n            font-size: 14px;\n            line-height: 30px;\n            font-family: microsoft yahei;\n            font-style: normal;\n            height: 30px\n        }\n        .ssd-module-wrap .W16036958418663 {\n            background-color: transparent;\n            color: #ffffff;\n            font-weight: normal;\n            letter-spacing: 0px;\n            text-decoration: none;\n            font-size: 12px;\n            line-height: 30px;\n            font-family: microsoft yahei;\n            font-style: normal;\n            height: 30px\n        }\n        .ssd-module-wrap .M16036958523494 {\n            width: 750px;\n            background-color: #FBFAFA;\n            background-size: 100% auto;\n            height: 155px\n        }\n        .ssd-module-wrap .W16036958546695 {\n            rotate: 0;\n            z-index: 0;\n            color: #000000;\n            font-weight: normal;\n            letter-spacing: 0px;\n            text-decoration: none;\n            font-size: 14px;\n            line-height: 1.5;\n            font-style: normal;\n            background-color: transparent;\n            top: 28px;\n            left: 34px;\n            width: 526px;\n            font-family: microsoft yahei;\n        }\n        .ssd-module-wrap .M16036959822456 {\n            width: 750px;\n            background-color: #b3b3b3;\n            background-size: 100% 100%;\n            background-image: url(http://img20.360buyimg.com/vc/jfs/t1/120088/4/17454/236346/5fa134eeEfb791a9e/cd719c7dd72c3807.jpg);\n            height: 562px\n        }\n        </style> \n  <br /> \n  <div class=\"ssd-module-wrap\"> \n   <div class=\"ssd-module ssd-module-heading M16036958418651\" id=\"detail-tag-id-424159\" name=\"detail-tag-id-424159\" text=\"产品信息\"> \n    <div class=\"ssd-module-heading-layout\"> \n     <span class=\"ssd-widget-heading-ch W16036958418662\">产品信息</span> \n     <span class=\"ssd-widget-heading-en W16036958418663\">Product Description</span> \n    </div> \n   </div> \n   <div class=\"ssd-module M16036958523494 animate-M16036958523494\" data-id=\"M16036958523494\"> \n    <div class=\"ssd-widget-text W16036958546695\">\n      ●产品特征： \n     <br />京苏 机用PP打包带 \n    </div> \n   </div> \n   <div class=\"ssd-module M16036959822456 animate-M16036959822456\" data-id=\"M16036959822456\"> \n   </div> \n  </div> \n  <!-- 2020-10-26 03:06:31 --> \n  <br /> \n  <br /> \n </div> \n <!-- #J-detail-content --> \n <div id=\"activity_footer\" clstag=\"shangpin|keycount|product|activityfooter\"></div> \n</div>",
                 *     "introMobile": "<div class=\"detail-content-item\"> \n <div id=\"activity_header\" clstag=\"shangpin|keycount|product|activityheader\"></div> \n <div id=\"J-detail-content\"> \n  <style>.ssd-module-wrap {\n            position: relative;\n            margin: 0 auto;\n            width: 750px;\n            text-align: left;\n            background-color: #fff\n        }\n        .ssd-module-wrap .ssd-module, .ssd-module-wrap .ssd-module-heading {\n            width: 750px;\n            position: relative;\n            overflow: hidden\n        }\n        .ssd-module-wrap .ssd-module {\n            background-repeat: no-repeat;\n            background-position: left top;\n            background-size: 100% 100%\n        }\n        .ssd-module-wrap .ssd-module-heading {\n            background-repeat: no-repeat;\n            background-position: left center;\n            background-size: 100% 100%\n        }\n        .ssd-module-wrap .ssd-module-heading .ssd-module-heading-layout {\n            display: inline-block\n        }\n        .ssd-module-wrap .ssd-module-heading .ssd-widget-heading-ch {\n            float: left;\n            display: inline-block;\n            margin: 0 6px 0 15px;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-module-heading .ssd-widget-heading-en {\n            float: left;\n            display: inline-block;\n            margin: 0 15px 0 6px;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-widget-circle, .ssd-module-wrap .ssd-widget-line, .ssd-module-wrap .ssd-widget-pic, .ssd-module-wrap .ssd-widget-rectangle, .ssd-module-wrap .ssd-widget-table, .ssd-module-wrap .ssd-widget-text, .ssd-module-wrap .ssd-widget-triangle {\n            position: absolute;\n            overflow: hidden\n        }\n        .ssd-module-wrap .ssd-widget-triangle svg {\n            width: 100%;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-widget-table table {\n            width: 100%;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-widget-table td {\n            position: relative;\n            white-space: pre-line;\n            word-break: break-all\n        }\n        .ssd-module-wrap .ssd-widget-pic img {\n            display: block;\n            width: 100%;\n            height: 100%\n        }\n        .ssd-module-wrap .ssd-widget-text {\n            line-height: 1.5;\n            word-break: break-all\n        }\n        .ssd-module-wrap .ssd-widget-text span {\n            display: block;\n            overflow: hidden;\n            width: 100%;\n            height: 100%;\n            padding: 0;\n            margin: 0;\n            word-break: break-all;\n            word-wrap: break-word;\n            white-space: normal\n        }\n        .ssd-module-wrap .M16036958418651 {\n            width: 750px;\n            background-color: transparent;\n            background-image: url(//img30.360buyimg.com/sku/jfs/t2467/315/1479078334/2361/4757d7d6/566010f4N01f5d17a.png);\n            height: 30px;\n            text-align: left\n        }\n        .ssd-module-wrap .W16036958418662 {\n            background-color: transparent;\n            color: #ffffff;\n            font-weight: normal;\n            letter-spacing: 0px;\n            text-decoration: none;\n            font-size: 14px;\n            line-height: 30px;\n            font-family: microsoft yahei;\n            font-style: normal;\n            height: 30px\n        }\n        .ssd-module-wrap .W16036958418663 {\n            background-color: transparent;\n            color: #ffffff;\n            font-weight: normal;\n            letter-spacing: 0px;\n            text-decoration: none;\n            font-size: 12px;\n            line-height: 30px;\n            font-family: microsoft yahei;\n            font-style: normal;\n            height: 30px\n        }\n        .ssd-module-wrap .M16036958523494 {\n            width: 750px;\n            background-color: #FBFAFA;\n            background-size: 100% auto;\n            height: 155px\n        }\n        .ssd-module-wrap .W16036958546695 {\n            rotate: 0;\n            z-index: 0;\n            color: #000000;\n            font-weight: normal;\n            letter-spacing: 0px;\n            text-decoration: none;\n            font-size: 14px;\n            line-height: 1.5;\n            font-style: normal;\n            background-color: transparent;\n            top: 28px;\n            left: 34px;\n            width: 526px;\n            font-family: microsoft yahei;\n        }\n        .ssd-module-wrap .M16036959822456 {\n            width: 750px;\n            background-color: #b3b3b3;\n            background-size: 100% 100%;\n            background-image: url(http://img20.360buyimg.com/vc/jfs/t1/120088/4/17454/236346/5fa134eeEfb791a9e/cd719c7dd72c3807.jpg);\n            height: 562px\n        }\n        </style> \n  <br /> \n  <div class=\"ssd-module-wrap\"> \n   <div class=\"ssd-module ssd-module-heading M16036958418651\" id=\"detail-tag-id-424159\" name=\"detail-tag-id-424159\" text=\"产品信息\"> \n    <div class=\"ssd-module-heading-layout\"> \n     <span class=\"ssd-widget-heading-ch W16036958418662\">产品信息</span> \n     <span class=\"ssd-widget-heading-en W16036958418663\">Product Description</span> \n    </div> \n   </div> \n   <div class=\"ssd-module M16036958523494 animate-M16036958523494\" data-id=\"M16036958523494\"> \n    <div class=\"ssd-widget-text W16036958546695\">\n      ●产品特征： \n     <br />京苏 机用PP打包带 \n    </div> \n   </div> \n   <div class=\"ssd-module M16036959822456 animate-M16036959822456\" data-id=\"M16036959822456\"> \n   </div> \n  </div> \n  <!-- 2020-10-26 03:06:31 --> \n  <br /> \n  <br /> \n </div> \n <!-- #J-detail-content --> \n <div id=\"activity_footer\" clstag=\"shangpin|keycount|product|activityfooter\"></div> \n</div>",
                 *     "issn": "0",
                 *     "catalogerCode": "yuanlei9",
                 *     "catalogerName": "袁磊",
                 *     "salerDeptId": "3422",
                 *     "salerDeptName": "通用品类岗",
                 *     "itemNum": "13X0452",
                 *     "isJIT": 0,
                 *     "isOverseaPurchase": 0,
                 *     "spwq": 0,
                 *     "dangerGoods": 0,
                 *     "afterSaleDesc": "",
                 *     "storeProperty": 0,
                 *     "designConcept": "",
                 *     "sysp": 0,
                 *     "giftsGoods": 0
                 * }
                 */

                // *     @FieldMeta(name = "SKUID", title = "商品SKU", length = 32)
                item.setSkuId(productInfo.getWareId());

                // *     @FieldMeta(name = "SKUNAME", title = "商品名称", length = 100)
                item.setSkuName(productInfo.getName());

                // *     @FieldMeta(name = "UUID", title = "uuid", length = 32)
                // item.setUuid(productInfo.getUuid());

                // *     @FieldMeta(name = "DIM1VAL", title = "第一维度的销售属性值", length = 100)
                // item.setDim1Val(productInfo.getDim1Val());

                // *     @FieldMeta(name = "DIM1SORT", title = "第一维度销售属性顺序", length = 8)
                // item.setDim1Sort(String.valueOf(skuInfoDto.getDim1Sort()));

                // *     @FieldMeta(name = "DIM2VAL", title = "第二维度的销售属性值", length = 100)
                // item.setDim2Val(skuInfoDto.getDim2Val());

                // *     @FieldMeta(name = "DIM2SORT", title = "第二维度销售属性顺序", length = 8)
                // item.setDim2Sort(String.valueOf(skuInfoDto.getDim2Sort()));

                // *     @FieldMeta(name = "OTHERSALEATTRIBUTE", title = "高维度(dim不小于3)销售属性列表", length = 1000)
                // TODO  高维度(dim不小于3)销售属性列表
                // item.setOtherSaleAttribute(skuInfoDto.getOtherSaleAttribute());

                // *     @FieldMeta(name = "MARKETPRICE", title = "市场价", length = 20)
                item.setMarketPrice(productInfo.getMarketPrice().stripTrailingZeros().toPlainString()); // 	900	市场价（小数点后保留2位）

                // *     @FieldMeta(name = "PURCHASEPRICE", title = "采购价", length = 20)
                item.setPurchasePrice(productInfo.getPurchasePrice().stripTrailingZeros().toPlainString()); // 700	采购价（小数点后保留2位）

                // *     @FieldMeta(name = "MEMBERPRICE", title = "京东价(", length = 20)
                item.setMemberPrice(productInfo.getMemberPrice().stripTrailingZeros().toPlainString()); // 700	800	京东价(（小数点后保留2位）

                // *     @FieldMeta(name = "WEIGHT", title = "商品重量", length = 20)
                item.setWeight(productInfo.getWeight().stripTrailingZeros().toPlainString()); // 	1.123	商品重量(单位：千克，含包装)小数点后保留3位

                // *     @FieldMeta(name = "LENGTH", title = "长度", length = 20)
                item.setLength(String.valueOf(productInfo.getLength())); // 	1.123	长度(单位：毫米，含包装)

                // *     @FieldMeta(name = "WIDTH", title = "宽度", length = 20)
                item.setWidth(String.valueOf(productInfo.getWidth())); // 	1.123	宽度(单位：毫米，含包装)

                // *     @FieldMeta(name = "HEIGHT", title = "高度", length = 20)
                item.setHeight(String.valueOf(productInfo.getHeight())); // 	1.123	高度(单位：毫米，含包装)

                // *     @FieldMeta(name = "UPC", title = "UPC编码", length = 20)
                item.setUpc(productInfo.getUpc()); // UPC编码（只包含字母和数字）

                // *     @FieldMeta(name = "ITEMNUM", title = "货号", length = 20)
                item.setItemNum(productInfo.getItemNum()); // 132 货号（货号不能包括中文，只能为英文或数字）

                //  Item原始数据属性
                // *     @FieldMeta(name = "ORIGINALCODE", title = "原始数据", length = 20)
                // item.set originalCode;

                // *     @FieldMeta(name = "MODEL", title = "制造商型号", length = 20)
                // item.set model;

                // *     @FieldMeta(name = "DELIVERYDATE", title = "发货日期", length = 30)
                // item.set deliverydate;

                // *     @FieldMeta(name = "UNIT", title = "销售单位", length = 20)
                // item.set unit;


                if ( insert ) {
                    SQLExecutor.insert(item);
                } else {
                    SQLExecutor.update(item);
                }


            }


            /**
             *  规格参数
             */
            if ( productInfo.getPropInfosList()!=null ) {
                for (PropSetting propSetting : productInfo.getPropInfosList()) {

                    VCPropInfo propInfo = null;
                    try {
                        propInfo =  SQLExecutor.executeQueryBean("select * from VC_PROP_INFO where WAREID = ? and PID = ? ", VCPropInfo.class, productInfo.getWareId(), propSetting.getPid());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    if ( propInfo==null ) {
                        propInfo = new VCPropInfo();
                        propInfo.setId(IdentifierGen.uuid());
                        propInfo.setWareId(productInfo.getWareId());
                        propInfo.setPid(propSetting.getPid());
                        propInfo.setVid(propSetting.getVid());
                        propInfo.setVname(propSetting.getVname());
                        propInfo.setRemark(propSetting.getRemark());

                        SQLExecutor.insert(propInfo);
                    } else {
                        propInfo.setWareId(productInfo.getWareId());
                        propInfo.setPid(propSetting.getPid());
                        propInfo.setVid(propSetting.getVid());
                        propInfo.setVname(propSetting.getVname());
                        propInfo.setRemark(propSetting.getRemark());
                        SQLExecutor.update(propInfo);
                    }

                }
            }



            /**
             * 扩展属性
             */
            if ( productInfo.getExtPropIInfosList()!=null ) {
                for (ExtPropDto extPropDto : productInfo.getExtPropIInfosList()) {

                    VCExtPropInfo extPropInfo = null;
                    try {
                        extPropInfo =  SQLExecutor.executeQueryBean("select * from VC_EXT_PROP_INFO where WAREID = ? and ATTID = ? ", VCExtPropInfo.class, productInfo.getWareId(), extPropDto.getAttId());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    if ( extPropInfo==null ) {
                        extPropInfo = new VCExtPropInfo();
                        extPropInfo.setId(IdentifierGen.uuid());
                        extPropInfo.setWareId(productInfo.getWareId());
                        extPropInfo.setCid(productInfo.getCid1());
                        extPropInfo.setAttid(extPropDto.getAttId());
                        extPropInfo.setCataclass(extPropDto.getCataClass());
                        extPropInfo.setName(extPropDto.getName());
                        extPropInfo.setType(extPropDto.getType());

                        SQLExecutor.insert(extPropInfo);
                    } else {
                        extPropInfo.setWareId(productInfo.getWareId());
                        extPropInfo.setCid(productInfo.getCid1());
                        extPropInfo.setAttid(extPropDto.getAttId());
                        extPropInfo.setCataclass(extPropDto.getCataClass());
                        extPropInfo.setName(extPropDto.getName());
                        extPropInfo.setType(extPropDto.getType());
                        SQLExecutor.update(extPropInfo);
                    }

                }
            }

        } else {
            System.out.println(new Gson().toJson(response.getJosResultDto().getSingleObj()));
        }

    }


}
